package com.j.lemon.learn.thread.UnsafeDemo;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @Author lijunjun
 * @Date 2019-10-23 15:39
 * @Description
 */
public class ArrayListUnSafeDemo {
//    private static List<Integer> list = new ArrayList<>();
    private static List<Integer> list = new CopyOnWriteArrayList<>();

    public static void main(String[] args) throws InterruptedException {

        for (int i = 0; i < 1000; i++) {
            new Thread(()->{
                for (int j = 0; j < 100; j++) {
                    list.add(j);
                }
            }).start();
        }
        Thread.sleep(5000);
        System.out.println(list.size());
    }


}
